#include <spdlog/spdlog.h>
#include <spdlog/sinks/stdout_color_sinks.h>
#include <spdlog/sinks/basic_file_sink.h>
#include <spdlog/async.h>
#include <iostream>

int main(int argc, char *argv[])
{

    spdlog::flush_every(std::chrono::seconds(1));
    spdlog::flush_on(spdlog::level::level_enum::debug);
    
    spdlog::set_level(spdlog::level::level_enum::debug);

    //初始化异步日志输出线程配置
    spdlog::init_thread_pool(3072, 1);
    //创建异步日志器（标准输出/文件）---工厂接口默认创建的就是同步日志器
    auto logger = spdlog::stdout_color_mt<spdlog::async_factory>("default-logger"); // 唯一区别就是工厂不同
    //auto logger = spdlog::basic_logger_mt("file-logger", "sync.log");

    logger->set_pattern("[%n][%H:%M:%S][%t][%-7l] %v");

    logger->debug("你好！{}", "程序猿");
    logger->info("你好！{}", "程序猿");
    logger->error("你好！{}", "程序猿");
    logger->trace("你好！{}", "程序猿");
    logger->warn("你好！{}", "程序猿");
    logger->critical("你好！{}", "程序猿");

    std::cout << "日志输出演示完毕!\n";
    return 0;
}